/*
 * @Descripttion:
 * @version:
 * @Author: chenbolin@msn.cn
 * @Date: 2021-05-20 10:35:50
 * @LastEditors: chenbolin@msn.cn
 * @LastEditTime: 2023-10-26 22:24:13
 */
#ifndef HAL_CONFIG_H
#define HAL_CONFIG_H

#define HAL_BOARD_TYPE_V1 1

#ifndef HAL_BOARD_TYPE
#define HAL_BOARD_TYPE HAL_BOARD_TYPE_V1
#endif

#define hPortA_Pin(p) (0x00 + p)
#define hPortB_Pin(p) (0x10 + p)
#define hPortC_Pin(p) (0x20 + p)
#define hPortD_Pin(p) (0x30 + p)
#define hPortE_Pin(p) (0x40 + p)
#define hPortF_Pin(p) (0x50 + p)

typedef enum
{
    // HAL_UART_PORT_1 = 0,
    // HAL_UART_PORT_2,
    HAL_UART_PORT_3 = 0,
    HAL_UART_COUNT
} HalUartPort_t;

#if (HAL_BOARD_TYPE == HAL_BOARD_TYPE_V1)
/*Fuction buttons*/

/*Board Keys*/
#define HAL_PIN_KEY_EMERGENCY_STOP hPortD_Pin(11) // 急停 DI_IN_04
#define HAL_PIN_KEY_ENGINE_START hPortC_Pin(9)    // 启动 DI_IN_06
#define HAL_PIN_KEY_ENGINE_STOP hPortC_Pin(8)     // 熄火 DI_IN_07
#define HAL_PIN_KEY_SPEED_MODE hPortD_Pin(12)     // 快慢速 DI_IN_03
#define HAL_PIN_KEY_HORN hPortD_Pin(14)           // 喇叭 DI_IN_01
#define HAL_PIN_KEY_LIGHTING hPortD_Pin(13)       // 照明 DI_IN_02

/*LED指示灯*/
#define HAL_PIN_OUT_LED_POWER_RED hPortE_Pin(6)    // 电源指示灯(红)
#define HAL_PIN_OUT_LED_POWER_GREEN hPortE_Pin(5)  // 电源指示灯(绿)
#define HAL_PIN_OUT_LED_SIGNAL_RED hPortE_Pin(4)   // 信号指示灯(红)
#define HAL_PIN_OUT_LED_SIGNAL_GREEN hPortE_Pin(3) // 信号指示灯(绿)

#define HAL_JOYSTICK_DUAL_CHANNEL_ENABLE    // 双路信号模式使能
#define HAL_JOYSTICK_SIGNAL_TYPE_CROSS 1    // 双交插曲线
#define HAL_JOYSTICK_SIGNAL_TYPE_SEPARATE 2 // 双独立信号

/*Joystick ADC Channel*/
#define HAL_ADC_JOYSTICK_DBSJ_A 9 // 大臂升降-A ADC_IN_02
#define HAL_ADC_JOYSTICK_DBSS_A 2 // 大臂伸缩-A ADC_IN_04
#define HAL_ADC_JOYSTICK_ZTXZ_A 0 // 转台旋转-A ADC_IN_06
#define HAL_ADC_JOYSTICK_DGSJ_A 5 // 吊钩升降-A ADC_IN_08

#if defined(HAL_JOYSTICK_DUAL_CHANNEL_ENABLE)

#define HAL_ADC_JOYSTICK_DBSJ_B 10 // 大臂升降-B ADC_IN_01
#define HAL_ADC_JOYSTICK_DBSS_B 14 // 大臂伸缩-B ADC_IN_03
#define HAL_ADC_JOYSTICK_ZTXZ_B 1  // 转台旋转-B ADC_IN_05
#define HAL_ADC_JOYSTICK_DGSJ_B 6  // 吊钩升降-B ADC_IN_7

#define HAL_JOYSTICK_DUAL_CHANNEL_TYPE HAL_JOYSTICK_SIGNAL_TYPE_SEPARATE // 双路信号类型

#endif

#endif

#define HAL_ADC_BATTERY 8   // 电池电量检测AD通道
#define HAL_ADC_THROTTLE 12 // 油门AD通道 ADC_IN_9
#define HAL_ADC_CHANNEL_NUM 15

#define HAL_PWM_TIMER_FREQUENCY 100000 // pwm定时器10us

#define HAL_SERAIL_PORT_LOGTXT HAL_UART_PORT_3 // 日志串口

#define KB(x) ((x) * 1024)
#define HAL_FLASH_SIZE (KB(1024))

#define HAL_FLASH_BASE_ADDR 0x8000000
#define HAL_FLASH_APP_ADDR (HAL_FLASH_BASE_ADDR + KB(16))
#define HAL_FLASH_OTA_ADDR (HAL_FLASH_BASE_ADDR + KB(128))
#define HAL_FLASH_SETTINGS_ADDR (HAL_FLASH_BASE_ADDR + KB(256))
#define HAL_FLASH_SETTINGS_BACKUP_ADDR (HAL_FLASH_BASE_ADDR + KB(384))
#define HAL_FLASH_LICENCE_KEY_ADDR (HAL_FLASH_BASE_ADDR + KB(512))
#define HAL_FLASH_OTA_INFO_ADDR (HAL_FLASH_BASE_ADDR + KB(640))

#endif
